<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>File Source for QPDBTests.php</title>
	<link rel="stylesheet" type="text/css" href="../media/style.css">
	<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
	<script src="media/a.js"></script>
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
	<td class="header-top-left"><img src="../media/logo.png" border="0" alt="phpDocumentor " /></td>
    <td class="header-top-right">Tests<br /><div class="header-top-right-subpackage"></div></td>
  </tr>
  <tr><td colspan="2" class="header-line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td colspan="2" class="header-menu">
      
                                                    
                      		[ <a href="../classtrees_Tests.html" class="menu">class tree: Tests</a> ]
		[ <a href="../elementindex_Tests.html" class="menu">index: Tests</a> ]
            [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td colspan="2" class="header-line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="195" class="menu">
		<div class="package-title">Tests</div>
  <div class="package">
	<div id="todolist">
			<p><a href="../todolist.html">Todo List</a></p>
	</div>
	</div>
      <b>Packages:</b><br />
  <div class="package">
              <a href="../li_QueryPath.html">QueryPath</a><br />
              <a href="../li_Examples.html">Examples</a><br />
              <a href="../li_Tests.html">Tests</a><br />
      	</div>
      <br />
                        <br />
                      </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<h1 align="center">Source for file QPDBTests.php</h1>
<p>Documentation is available at <a href="../Tests/_test---QPDBTests.php.html">QPDBTests.php</a></p>
<div class="src-code"><span class="php">
<ol><li><div class="src-line"><a name="a1"></a><span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line"><a name="a2"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">&nbsp;*&nbsp;Tests&nbsp;for&nbsp;the&nbsp;QueryPath&nbsp;library.</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@package</span><span class="src-doc">&nbsp;Tests</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@author</span><span class="src-doc">&nbsp;M&nbsp;Butcher&nbsp;&lt;matt@aleph-null.tv&gt;</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@license</span><span class="src-doc">&nbsp;The&nbsp;GNU&nbsp;Lesser&nbsp;GPL&nbsp;(LGPL)&nbsp;or&nbsp;an&nbsp;MIT-like&nbsp;license.</span></div></li>
<li><div class="src-line"><a name="a7"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a8"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a9"></a><span class="src-inc">require_once&nbsp;</span><span class="src-str">'PHPUnit/Framework.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a10"></a><span class="src-inc">require_once&nbsp;</span><span class="src-str">'../src/QueryPath/QueryPath.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a11"></a><span class="src-inc">require_once&nbsp;</span><span class="src-str">'../src/QueryPath/Extension/QPDB.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a12"></a><span class="src-inc">require_once&nbsp;</span><span class="src-str">'../src/QueryPath/Extension/QPTPL.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a13"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-id"><a href="../QueryPath/Extension/QPDB.html">QPDB</a></span><span class="src-sym">::</span><a href="../QueryPath/Extension/QPDB.html#methodbaseDB">baseDB</a><span class="src-sym">(</span><span class="src-str">'sqlite:./db/qpTest.db'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a15"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a16"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a17"></a><span class="src-key">class&nbsp;</span><a href="../Tests/QPDBTests.html">QPDBTests</a>&nbsp;<span class="src-key">extends&nbsp;</span><span class="src-id">PHPUnit_Framework_TestCase&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a18"></a>&nbsp;&nbsp;<span class="src-key">private&nbsp;</span><span class="src-var">$dsn&nbsp;</span>=&nbsp;<span class="src-str">'sqlite:./db/qpTest.db'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a19"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a20"></a>&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Tests/QPDBTests.html#methodsetUp">setUp</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a21"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">db&nbsp;</span>=&nbsp;<span class="src-id"><a href="../QueryPath/Extension/QPDB.html">QPDB</a></span><span class="src-sym">::</span><a href="../QueryPath/Extension/QPDB.html#methodgetBaseDB">getBaseDB</a><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a22"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">db</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'CREATE&nbsp;TABLE&nbsp;IF&nbsp;NOT&nbsp;EXISTS&nbsp;qpdb_test&nbsp;(colOne,&nbsp;colTwo,&nbsp;colThree)'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a23"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a24"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$stmt&nbsp;</span>=&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">db</span><span class="src-sym">-&gt;</span><span class="src-id">prepare</span><span class="src-sym">(</span></div></li>
<li><div class="src-line"><a name="a25"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-str">'INSERT&nbsp;INTO&nbsp;qpdb_test&nbsp;(colOne,&nbsp;colTwo,&nbsp;colThree)&nbsp;VALUES&nbsp;(:one,&nbsp;:two,&nbsp;:three)'</span></div></li>
<li><div class="src-line"><a name="a26"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a27"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a28"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">for&nbsp;</span><span class="src-sym">(</span><span class="src-var">$i&nbsp;</span>=&nbsp;<span class="src-num">0</span><span class="src-sym">;&nbsp;</span><span class="src-var">$i&nbsp;</span>&lt;&nbsp;<span class="src-num">5</span><span class="src-sym">;&nbsp;</span>++<span class="src-var">$i</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a29"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$vals&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-str">':one'&nbsp;</span>=&gt;&nbsp;<span class="src-str">'Title&nbsp;'&nbsp;</span>.&nbsp;<span class="src-var">$i</span><span class="src-sym">,&nbsp;</span><span class="src-str">':two'&nbsp;</span>=&gt;&nbsp;<span class="src-str">'Body&nbsp;'&nbsp;</span>.&nbsp;<span class="src-var">$i</span><span class="src-sym">,&nbsp;</span><span class="src-str">':three'&nbsp;</span>=&gt;&nbsp;<span class="src-str">'Footer&nbsp;'&nbsp;</span>.&nbsp;<span class="src-var">$i</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a30"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$stmt</span><span class="src-sym">-&gt;</span><span class="src-id">execute</span><span class="src-sym">(</span><span class="src-var">$vals</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a31"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$stmt</span><span class="src-sym">-&gt;</span><span class="src-id">closeCursor</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a32"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a33"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a34"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a35"></a>&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Tests/QPDBTests.html#methodtearDown">tearDown</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a36"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">db</span><span class="src-sym">-&gt;</span><span class="src-id">exec</span><span class="src-sym">(</span><span class="src-str">'DROP&nbsp;TABLE&nbsp;qpdb_test'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a37"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a38"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a39"></a>&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Tests/QPDBTests.html#methodtestQueryInto">testQueryInto</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a40"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//&nbsp;This&nbsp;is&nbsp;the&nbsp;only&nbsp;query&nbsp;that&nbsp;uses&nbsp;dbInit().</span></div></li>
<li><div class="src-line"><a name="a41"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql&nbsp;</span>=&nbsp;<span class="src-str">'SELECT&nbsp;&quot;Hello&quot;,&nbsp;&quot;World&quot;'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a42"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$qp&nbsp;</span>=&nbsp;<a href="../QueryPath/_src---QueryPath---QueryPath.php.html#functionqp">qp</a><span class="src-sym">(</span><span class="src-id"><a href="../QueryPath/QueryPath.html">QueryPath</a></span><span class="src-sym">::</span><span class="src-id">HTML_STUB</span><span class="src-sym">,&nbsp;</span><span class="src-str">'body'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">dbInit</span><span class="src-sym">(</span><span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-var">dsn</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">queryInto</span><span class="src-sym">(</span><span class="src-var">$sql</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">doneWithQuery</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a43"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">assertEquals</span><span class="src-sym">(</span><span class="src-str">'HelloWorld'</span><span class="src-sym">,&nbsp;</span><span class="src-var">$qp</span><span class="src-sym">-&gt;</span><span class="src-id">top</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'body'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a44"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a45"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$template&nbsp;</span>=&nbsp;<span class="src-str">'&lt;?xml&nbsp;version=&quot;1.0&quot;?&gt;&lt;li&nbsp;class=&quot;colOne&quot;/&gt;'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a46"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql&nbsp;</span>=&nbsp;<span class="src-str">'SELECT&nbsp;*&nbsp;FROM&nbsp;qpdb_test'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a47"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$args&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a48"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$qp&nbsp;</span>=&nbsp;<a href="../QueryPath/_src---QueryPath---QueryPath.php.html#functionqp">qp</a><span class="src-sym">(</span><span class="src-id"><a href="../QueryPath/QueryPath.html">QueryPath</a></span><span class="src-sym">::</span><span class="src-id">HTML_STUB</span><span class="src-sym">,&nbsp;</span><span class="src-str">'body'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;ul/&gt;'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">children</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">queryInto</span><span class="src-sym">(</span><span class="src-var">$sql</span><span class="src-sym">,&nbsp;</span><span class="src-var">$args</span><span class="src-sym">,&nbsp;</span><span class="src-var">$template</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">doneWithQuery</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a49"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//$qp-&gt;writeHTML();</span></div></li>
<li><div class="src-line"><a name="a50"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">assertEquals</span><span class="src-sym">(</span><span class="src-num">5</span><span class="src-sym">,&nbsp;</span><span class="src-var">$qp</span><span class="src-sym">-&gt;</span><span class="src-id">top</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'li'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">size</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a51"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a52"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$template&nbsp;</span>=&nbsp;<span class="src-str">'&lt;?xml&nbsp;version=&quot;1.0&quot;?&gt;&lt;tr&gt;&lt;td&nbsp;class=&quot;colOne&quot;/&gt;&lt;td&nbsp;class=&quot;colTwo&quot;/&gt;&lt;td&nbsp;class=&quot;colThree&quot;/&gt;&lt;/tr&gt;'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a53"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql&nbsp;</span>=&nbsp;<span class="src-str">'SELECT&nbsp;*&nbsp;FROM&nbsp;qpdb_test'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a54"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$args&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a55"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$qp&nbsp;</span>=&nbsp;<a href="../QueryPath/_src---QueryPath---QueryPath.php.html#functionqp">qp</a><span class="src-sym">(</span><span class="src-id"><a href="../QueryPath/QueryPath.html">QueryPath</a></span><span class="src-sym">::</span><span class="src-id">HTML_STUB</span><span class="src-sym">,&nbsp;</span><span class="src-str">'body'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a56"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Title&lt;/th&gt;&lt;th&gt;Body&lt;/th&gt;&lt;th&gt;Foot&lt;/th&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a57"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'tbody'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a58"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">queryInto</span><span class="src-sym">(</span><span class="src-var">$sql</span><span class="src-sym">,&nbsp;</span><span class="src-var">$args</span><span class="src-sym">,&nbsp;</span><span class="src-var">$template</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a59"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">doneWithQuery</span><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a60"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">;</span><span class="src-comm">//-&gt;writeHTML();</span></div></li>
<li><div class="src-line"><a name="a61"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">assertEquals</span><span class="src-sym">(</span><span class="src-str">'Footer&nbsp;4'</span><span class="src-sym">,&nbsp;</span><span class="src-var">$qp</span><span class="src-sym">-&gt;</span><span class="src-id">top</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'td:last'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a62"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a63"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a64"></a>&nbsp;&nbsp;<span class="src-comm">/*</span></div></li>
<li><div class="src-line"><a name="a65"></a><span class="src-comm">&nbsp;&nbsp;public&nbsp;function&nbsp;xtestExec()&nbsp;{</span></div></li>
<li><div class="src-line"><a name="a66"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;$sql&nbsp;=&nbsp;'INSERT&nbsp;INTO&nbsp;qpdb_test&nbsp;(colOne,&nbsp;colTwo,&nbsp;colThree)&nbsp;VALUES&nbsp;(&quot;o&quot;,&nbsp;&quot;t&quot;,&nbsp;&quot;tr&quot;)';</span></div></li>
<li><div class="src-line"><a name="a67"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;$qp&nbsp;=&nbsp;qp()-&gt;exec($sql)-&gt;doneWithQuery();</span></div></li>
<li><div class="src-line"><a name="a68"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;assertEquals(6,&nbsp;$qp-&gt;query('SELECT&nbsp;count(*)&nbsp;as&nbsp;c&nbsp;FROM&nbsp;qpdb_test')-&gt;getStatement()-&gt;fetchObject()-&gt;c);</span></div></li>
<li><div class="src-line"><a name="a69"></a><span class="src-comm">&nbsp;&nbsp;&nbsp;&nbsp;$qp-&gt;doneWithQuery();</span></div></li>
<li><div class="src-line"><a name="a70"></a><span class="src-comm">&nbsp;&nbsp;}</span></div></li>
<li><div class="src-line"><a name="a71"></a><span class="src-comm">&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a72"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a73"></a>&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../Tests/QPDBTests.html#methodtestQueryChains">testQueryChains</a><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a74"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$sql&nbsp;</span>=&nbsp;<span class="src-str">'SELECT&nbsp;*&nbsp;FROM&nbsp;qpdb_test'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a75"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$args&nbsp;</span>=&nbsp;<span class="src-key">array</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a76"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$qp&nbsp;</span>=&nbsp;<a href="../QueryPath/_src---QueryPath---QueryPath.php.html#functionqp">qp</a><span class="src-sym">(</span><span class="src-id"><a href="../QueryPath/QueryPath.html">QueryPath</a></span><span class="src-sym">::</span><span class="src-id">HTML_STUB</span><span class="src-sym">,&nbsp;</span><span class="src-str">'body'</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Open&nbsp;a&nbsp;stub&nbsp;HTML&nbsp;doc&nbsp;and&nbsp;select&nbsp;&lt;body/&gt;</span></div></li>
<li><div class="src-line"><a name="a77"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;h1&gt;&lt;/h1&gt;'</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Add&nbsp;&lt;h1/&gt;</span></div></li>
<li><div class="src-line"><a name="a78"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">children</span><span class="src-sym">(</span><span class="src-sym">)&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;Select&nbsp;the&nbsp;&lt;h1/&gt;</span></div></li>
<li><div class="src-line"><a name="a79"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//-&gt;dbInit($this-&gt;dsn)&nbsp;//&nbsp;Connect&nbsp;to&nbsp;the&nbsp;database</span></div></li>
<li><div class="src-line"><a name="a80"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-var">$sql</span><span class="src-sym">,&nbsp;</span><span class="src-var">$args</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Execute&nbsp;the&nbsp;SQL&nbsp;query</span></div></li>
<li><div class="src-line"><a name="a81"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">nextRow</span><span class="src-sym">(</span><span class="src-sym">)&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;Select&nbsp;a&nbsp;row.&nbsp;By&nbsp;default,&nbsp;no&nbsp;row&nbsp;is&nbsp;selected.</span></div></li>
<li><div class="src-line"><a name="a82"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-comm">//-&gt;withEachRow()</span></div></li>
<li><div class="src-line"><a name="a83"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">appendColumn</span><span class="src-sym">(</span><span class="src-str">'colOne'</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Append&nbsp;Row&nbsp;1,&nbsp;Col&nbsp;1&nbsp;(Title&nbsp;0)</span></div></li>
<li><div class="src-line"><a name="a84"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">parent</span><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Go&nbsp;back&nbsp;to&nbsp;the&nbsp;&lt;body/&gt;</span></div></li>
<li><div class="src-line"><a name="a85"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;p/&gt;'</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Append&nbsp;a&nbsp;&lt;p/&gt;&nbsp;to&nbsp;the&nbsp;body</span></div></li>
<li><div class="src-line"><a name="a86"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'p'</span><span class="src-sym">)&nbsp;&nbsp;</span><span class="src-comm">//&nbsp;Find&nbsp;the&nbsp;&lt;p/&gt;&nbsp;we&nbsp;just&nbsp;created.</span></div></li>
<li><div class="src-line"><a name="a87"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">nextRow</span><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Advance&nbsp;to&nbsp;row&nbsp;2</span></div></li>
<li><div class="src-line"><a name="a88"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">prependColumn</span><span class="src-sym">(</span><span class="src-str">'colTwo'</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Get&nbsp;row&nbsp;2,&nbsp;col&nbsp;2.&nbsp;(Body&nbsp;1)</span></div></li>
<li><div class="src-line"><a name="a89"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">columnAfter</span><span class="src-sym">(</span><span class="src-str">'colThree'</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Get&nbsp;row&nbsp;2&nbsp;col&nbsp;3.&nbsp;(Footer&nbsp;1)</span></div></li>
<li><div class="src-line"><a name="a90"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">doneWithQuery</span><span class="src-sym">(</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Let&nbsp;QueryPath&nbsp;clean&nbsp;up.</span></div></li>
<li><div class="src-line"><a name="a91"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">;</span><span class="src-comm">//-&gt;writeHTML();&nbsp;//&nbsp;Write&nbsp;the&nbsp;output&nbsp;as&nbsp;HTML.</span></div></li>
<li><div class="src-line"><a name="a92"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">assertEquals</span><span class="src-sym">(</span><span class="src-str">'Title&nbsp;0'</span><span class="src-sym">,&nbsp;</span><span class="src-var">$qp</span><span class="src-sym">-&gt;</span><span class="src-id">top</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'h1'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a93"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">assertEquals</span><span class="src-sym">(</span><span class="src-str">'Body&nbsp;1'</span><span class="src-sym">,&nbsp;</span><span class="src-var">$qp</span><span class="src-sym">-&gt;</span><span class="src-id">top</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'p'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a94"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a95"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$qp&nbsp;</span>=&nbsp;<a href="../QueryPath/_src---QueryPath---QueryPath.php.html#functionqp">qp</a><span class="src-sym">(</span><span class="src-id"><a href="../QueryPath/QueryPath.html">QueryPath</a></span><span class="src-sym">::</span><span class="src-id">HTML_STUB</span><span class="src-sym">,&nbsp;</span><span class="src-str">'body'</span><span class="src-sym">)&nbsp;</span><span class="src-comm">//&nbsp;Open&nbsp;a&nbsp;stub&nbsp;HTML&nbsp;doc&nbsp;and&nbsp;select&nbsp;&lt;body/&gt;</span></div></li>
<li><div class="src-line"><a name="a96"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;table&gt;&lt;tbody/&gt;&lt;/table&gt;'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a97"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'tbody'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a98"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-str">'SELECT&nbsp;*&nbsp;FROM&nbsp;qpdb_test&nbsp;LIMIT&nbsp;2'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a99"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">withEachRow</span><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a100"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">appendColumn</span><span class="src-sym">(</span><span class="src-str">'colOne'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a101"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">doneWithQuery</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a102"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">assertEquals</span><span class="src-sym">(</span><span class="src-str">'Title&nbsp;0Title&nbsp;1'</span><span class="src-sym">,&nbsp;</span><span class="src-var">$qp</span><span class="src-sym">-&gt;</span><span class="src-id">top</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'tbody'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a103"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a104"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$wrap&nbsp;</span>=&nbsp;<span class="src-str">'&lt;?xml&nbsp;version=&quot;1.0&quot;?&gt;&lt;tr&gt;&lt;td/&gt;&lt;/tr&gt;'</span><span class="src-sym">;&nbsp;&nbsp;&nbsp;&nbsp;</span></div></li>
<li><div class="src-line"><a name="a105"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$qp&nbsp;</span>=&nbsp;<a href="../QueryPath/_src---QueryPath---QueryPath.php.html#functionqp">qp</a><span class="src-sym">(</span><span class="src-id"><a href="../QueryPath/QueryPath.html">QueryPath</a></span><span class="src-sym">::</span><span class="src-id">HTML_STUB</span><span class="src-sym">,&nbsp;</span><span class="src-str">'body'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a106"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;table&gt;&lt;tbody/&gt;&lt;/table&gt;'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a107"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'tbody'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a108"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">query</span><span class="src-sym">(</span><span class="src-str">'SELECT&nbsp;*&nbsp;FROM&nbsp;qpdb_test&nbsp;LIMIT&nbsp;2'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a109"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">withEachRow</span><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a110"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">appendColumn</span><span class="src-sym">(</span><span class="src-str">'colOne'</span><span class="src-sym">,&nbsp;</span><span class="src-var">$wrap</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a111"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">doneWithQuery</span><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a112"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">;</span><span class="src-comm">//-&gt;writeHTML();</span></div></li>
<li><div class="src-line"><a name="a113"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$this</span><span class="src-sym">-&gt;</span><span class="src-id">assertEquals</span><span class="src-sym">(</span><span class="src-str">'Title&nbsp;0'</span><span class="src-sym">,&nbsp;</span><span class="src-var">$qp</span><span class="src-sym">-&gt;</span><span class="src-id">top</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'td:first'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-sym">))</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a114"></a>&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a115"></a><span class="src-sym">}</span></div></li>
</ol>
</span></div>
        <div class="credit">
		    <hr class="separator" />
		    Documentation generated on Thu, 19 Mar 2009 18:01:12 -0500 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.2</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>